"""
业务日志 VO
"""

import utils.enum_utils as enum
from models import (
    VOBase,
    VOPage,
)
from utils.mock_utils import Demo
from utils.validator_utils.pydantic_validator.field import (
    CharField,
    IntegerField,
)


class BizLogFileListVO(VOBase):
    """ 业务日志文件 | 列表 | VO """

    file_date: str = CharField(..., title="日期", min_length=10, max_length=10, examples=[Demo.date_str])
    file_name: str = CharField(..., title="文件名", max_length=32, examples=[f"{Demo.date_str}.log"])
    file_size: int = IntegerField(..., title="文件大小（Bytes）")
    log_count: int = IntegerField(..., title="日志条数")


class BizLogFileListPage(VOPage[BizLogFileListVO]):
    """ 业务日志文件 | 列表 | 分页 """


class BizLogListVO(VOBase):
    """ 业务日志 | 列表 | VO """

    code_path: str = CharField(..., title="代码路径", max_length=64, examples=["api.common.file_api"])
    code_file: str = CharField(..., title="代码文件", max_length=32, examples=["file_api.py"])
    code_line: int = IntegerField(..., title="代码行号", min_value=1, max_value=8192)
    log_level: enum.LoguruLogLevel = CharField(..., title="日志级别")
    log_time: str = CharField(..., title="日志时间", min_length=23, max_length=23, examples=[Demo.dt_str_full])
    log_line: int = IntegerField(..., title="日志行号", min_value=1)
    message: str = CharField(..., title="日志信息")
    process_id: int = IntegerField(..., title="进程 ID", min_value=1, max_value=2 ** 32 - 1)
    thread_id: int = IntegerField(..., title="线程 ID", min_value=1, max_value=2 ** 32 - 1)


class BizLogListPage(VOPage[BizLogListVO]):
    """ 业务日志 | 列表 | 分页 """
